import request from '@/utils/request'

///api/reg POST  注册
export const userRegisterService = ({ username, password, repassword }) =>
  request.post('/api/reg', { username, password, repassword })

///api/login POST 登录
export const userLoginService = ({ username, password }) =>
  request.post('/api/login', { username, password })
///my/userinfo GET 获取用户信息
export const getUserInfoService = () => request.get('/my/userinfo')

// /my/update/avatar patch 更新头像
export const updateAvatarService = (avatar) =>
  request.patch('/my/update/avatar', { avatar })
//    /my/updatepwd patch 更新密码
export const updatePwdService = ({ old_pwd, new_pwd, re_pwd }) =>
  request.patch('/my/updatepwd', { old_pwd, new_pwd, re_pwd })
//    /my/userinfo put 更新用户信息
// {
//     "id": 10,
//     "nickname": "杜秀英",
//     "email": "k.acpwpn@qq.com",
//     "username": "范敏",
//     "user_pic": null
//   }
export const updateUserInfoService = (userinfo) =>
  request.put('/my/userinfo', userinfo)
